package pk.campustour;

import java.util.ArrayList;
import java.util.Arrays;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
 
public class CategoryActivity extends ListActivity {
	private ListView mainListView ;  
	private ArrayAdapter<String> listAdapter ;
	private  String[] categories;
	private ArrayList<String> categoryList;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_category);

		  // Find the ListView resource.   
		  mainListView = (ListView) findViewById(android.R.id.list); 
		  
		  // Create and populate a List of planet names.  
		  categories = new String[] { "Department", "Hostel", "Cafeteria", "Market",  
		                                  "Park", "Hospital", "Mosque", "Residential Area"};    
		  categoryList = new ArrayList<String>();  
		  categoryList.addAll( Arrays.asList(categories) );  

		 
		 
		  //mainListView.setAdapter(new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_list_item_1, categories));
		  

		  listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, categoryList);
		  listAdapter.add( "VC Office" );  
		  listAdapter.add( "Bus Stop" ); 
		  listAdapter.add( "Bank" ); 
		  listAdapter.add( "Library" ); 
		  

		  // Set the ArrayAdapter as the ListView's adapter.  
		  //ListFragment.setListAdapter(listAdapter);
		  //AlertDialog dialog=new
		 mainListView.setAdapter(listAdapter);
		 

    }
	@Override
    public void onListItemClick(ListView l, View v, int position, long id)
    {
    	String item = (String) listAdapter.getItem(position);
    	Toast.makeText(CategoryActivity.this,"Item Selected " + item, Toast.LENGTH_SHORT).show();
		Intent in=new Intent(CategoryActivity.this,PlacesActivity.class);
		//Bundle bundle=new Bundle();
		//bundle.putString("Item", item);
		//in.putExtras(bundle);
		startActivity(in);
    }
}